package com.yzw.acl.controller;

import com.yzw.common.domain.EduAclPermission;
import com.yzw.common.dto.R;
import com.yzw.common.service.EduAclPermissionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Yzw
 * @Description TODO
 * @Date 2023/5/17 19:41
 * @Version 1.0
 */
@RestController
@RequestMapping("/acl/permission")
public class PermissionController {
    @Resource
    EduAclPermissionService eduAclPermissionService;

    @ApiOperation("查询所有菜单")
    @GetMapping()
    public R selAllPermission() {
        List<EduAclPermission> eduAclPermissions = eduAclPermissionService.selAllPermission();
        return R.success("查询所有菜单成功", eduAclPermissions);
    }

    @ApiOperation("删除菜单")
    @DeleteMapping("{id}")
    public R removePermission(@PathVariable String id) {
        eduAclPermissionService.removePermission(id);
        return R.success("删除菜单成功", null);
    }


    @ApiOperation("给角色分配菜单")
    @PostMapping("/{roleId}/{permissionIds}")
    public R rolePermission(@PathVariable String roleId,@PathVariable String[] permissionIds) {
        eduAclPermissionService.rolePermission(roleId,permissionIds);
        return R.success("删除菜单成功", null);
    }
}
